<template>
	<view class="" style="background-color: #f8f8f8;">
		<view class="" style="height: 26rpx;"></view>
		<view class="" style="background-color: #fff;padding: 0 30rpx;">
			<u-form :model="form" ref="uForm">
					<u-form-item label="报关单号" label-width="220">
						<u-input v-model="form.customsCode" disabled />
					</u-form-item>
					<u-form-item label="客户名称" label-width="220">
						<u-input v-model="form.customerName" />
					</u-form-item>
					
					<u-form-item label="供应商名称" label-width="220">
						<u-input v-model="form.supplierName" />
					</u-form-item>
					<u-form-item label="进/出口" label-width="220">
						<u-input v-model="form.ioTypeN" type="select" @click="show = true" />
						<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
					</u-form-item>
					<u-form-item label="申报单位名称" label-width="220">
						<u-input v-model="form.agentName" />
					</u-form-item>
					<u-form-item label="运输方式" label-width="220">
						<u-input v-model="form.transTypeCodeN" type="select" @click="show2 = true" />
						<u-select v-model="show2" :list="list2" @confirm="confirm2"></u-select>
					</u-form-item>
					<u-form-item :label="transportNameN" label-width="220">
						<u-input v-model="form.transportName" />
					</u-form-item>
					<u-form-item label="备注" label-width="220">
						<u-input v-model="form.remark" />
					</u-form-item>
					<!-- <u-form-item label="电子委托编码" label-width="220">
						<u-input v-model="form.delegationCode" />
					</u-form-item>
					<u-form-item label="自定义参考号" label-width="220">
						<u-input v-model="form.refCode" />
					</u-form-item>
					<u-form-item label="报关方式/类型" label-width="220">
						<u-input v-model="form.declTypeN" type="select" @click="show2 = true" />
						<u-select v-model="show2" :list="list2" @confirm="confirm2"></u-select>
					</u-form-item>
					<u-form-item label="申报地海关代码" label-width="220">
						<u-input v-model="form.agentCustomsCode" />
					</u-form-item> -->
				</u-form>
		</view>
		<view class="" style="padding: 0 30rpx;position: absolute;bottom: 100rpx;width: 100%;">
			<u-button type="primary" shape="circle" @click="submit">提交</u-button>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			id:'',
			order:{},
			form: {
				customerName: '',
				customsCode: '',
				customsSeqno: '',
				passTime: '',
				delegationCode: '',
				refCode:'',
				ioTypeN:'',
				ioType:'',
				declType:'',
				declTypeN:'',
				agentCustomsCode:''
			},
			transportNameN:'',
			show: false,
			show2: false,
			list: [
				{
					value: '1',
					label: '出口'
				},
				{
					value: '2',
					label: '进口'
				}
			],
			list2: [
				{
					value: '1',
					label: '铁路'
				},
				{
					value: '2',
					label: '公路'
				},
				{
					value: '3',
					label: '海运'
				},
				{
					value: '4',
					label: '空运'
				}
			],
			value: '',
			type: 'textarea',
			border: true,
			height: 100,
			autoHeight: true,
			radio: '',
			switchVal: false
		};
	},
	onLoad(option) {
		console.log(option)
		this.order = JSON.parse(option.orderDetail)
		// this.getOrderDetail()
		console.log(this.order)
		this.form = this.order
		if(this.form.ioType==1){
			this.form.ioTypeN = '出口'
		}else
		if(this.form.ioType==2){
			this.form.ioTypeN = '进口'
		}
		if(this.form.transTypeCode == 1){
			this.form.transTypeCodeN = '铁路'
			this.transportNameN = '集装箱号'
		}else
		if(this.form.transTypeCode==2){
			this.form.transTypeCodeN = '公路'
			this.transportNameN = '车牌号'
		}
		if(this.form.transTypeCode == 3){
			this.form.transTypeCodeN = '海运'
			this.transportNameN = '柜号'
		}else
		if(this.form.transTypeCode==4){
			this.form.transTypeCodeN = '空运'
			this.transportNameN = '航次号'
		}


	},
	methods:{
		confirm(e) {
			console.log(e);
			this.form.ioTypeN = e[0].label
			this.form.ioType = e[0].value
		},
		confirm2(e) {
			console.log(e);
			if(e[0].value==1){
				this.transportNameN = '集装箱号'
			}
			if(e[0].value==2){
				this.transportNameN = '车牌号'
			}
			if(e[0].value==3){
				this.transportNameN = '柜号'
			}
			if(e[0].value==4){
				this.transportNameN = '航次号'
			}
			this.form.transTypeCodeN = e[0].label
			this.form.transTypeCode = e[0].value
		},
		async submit(){
			// customerName: '',
			// customsCode: '',
			// customsSeqno: '',
			// passTime: '',
			// delegationCode: '',
			// refCode:'',
			// ioTypeN:'',
			// ioType:'',
			// declType:'',
			// agentCustomsCode:''
			console.log(this.form)
			this.form.id = this.order.id
			const res = await this.$api.EditOrder(
			{
			'id':this.order.id,
			'customerName':this.form.customerName,
			'customsCode':this.form.customsCode,
			'manufactureName':this.form.manufactureName,
			'ioType':this.form.ioType,
			'agentName':this.form.agentName,
			'transTypeCode':this.form.transTypeCode,
			'transportName':this.form.transportName,
			'remark':this.form.remark
			}
			)
			console.log(res)
			if(res.code==1){
				uni.navigateBack()
			}else{
				this.$refs.uToast.show({
					title: res.msg,
					type: 'error'
				})
			}
		}
	}
};
</script>

<style>
</style>